#include "Connector.h"
#include "Addr.h"
#include "Stream.h"
#include "Log.h"

int Connector::connect( const Addr &localAddr,const Addr &remoteAddr,Stream & stream){
	if(!this.open(AF_INET,SOCK_STREAM,0,i))	{
		Log::error("connetor open socket error");
		return 0;
	}
	const struct sockaddr_in *addr = localAddr.get_addr();
	if(connect(this->getHandle(),(const struct sockaddr*)(addr),sizeof(*addr)) == -1)
        {
		Log::error("connect error ");	
		return 0;
	}	
	stream.set_handle(this->getHandle());
	return 1;
}
